package question2;

import java.util.Comparator;
import java.util.TreeSet;

public class TreeSetDemo {
    public static void main(String[] args) {
        TreeSet<Car> cars = new TreeSet<>(new Comparator<Car>() {
            @Override
            public int compare(Car o1, Car o2) {
                return o1.getNumber()-o2.getNumber()==0?o1.getNumber()-o2.getPrice()==0?o2.getBrand().compareTo(o1.getBrand()):o1.getNumber()-o2.getPrice():o1.getNumber()-o2.getNumber();
            }
        });
        cars.add(new Car("BenChi", 30, 2000));
        cars.add(new Car("BaoMa", 30, 2500));
        cars.add(new Car("AoDi", 25, 3000));
        cars.add(new Car("BaoShiJie", 50, 2000));
        cars.add(new Car("Wulinhongguang", 10, 8000));
        cars.add(new Car("ChangCheng", 10, 8000));
        cars.add(new Car("LanBoJini", 90, 1000));
        cars.forEach(c-> System.out.println(c));
    }
}
